NetCloak 2.5 User's Guide

Cookie Commands


Cookies, like other kinds of variables, are made up of two parts: a name and a value. They are transferred in the HTTP header of both user requests and server responses, and are stored by the browser.

When the user asks for a page, the server is allowed to send a cookie in the header (it won't be seen in the HTML page) along with the response page it would normally send. The browser is expected to store the cookie so that when it makes subsequent requests of the server it can send the cookie name and value.

NetCloak gives you the ability to create cookies, and it even makes them easy. Cookies have lots of uses, and are actually a lot like user variables. In some cases, local variables may be better because they can be tracked even when a browser doesn't support them and the data doesn't need to be constantly resent by the browser. On the other hand, cookies have the capability of sharing information among multiple servers, or between different add-on tools on the same server. Cookies are also more reliable when users may be coming through proxy servers or have dynamic IP addresses.

Even if you prefer to use user variables, cookies can be used to help NetCloak track the variables. For users dialing in using shared modem pools or proxy servers, cookies give NetCloak a reliable way to track the user variable data.

<SET_COOKIE CookieName = Value>

NetCloak supports a "default cookie", called "NetCloakID". When this cookie is found, it will use the cookie's value as a key to the user variable data, instead of the user's IP address. To create a randomized default cookie, use the command:

     <SET_COOKIE>

For example, the command SET_COOKIE on your server's home page will generate a string and send it as a cookie named "NetCloakID". If accepted by the browser, all subsequent user variable operations (using either "SET_VARIABLE" or forms submitted by the user) will store the variable data based on this randomized key. If the browser refuses the cookie (either it doesn't support cookies or the user chooses not to accept it), then NetCloak will store user variables using the user's IP address as the key. If you are using User variables on your site, it is recommended that you include a SET_COOKIE command on your home page to improve tracking of users.

In addition to the default cookie, you can also specify up to eight additional cookies per user, named whatever you like. A cookie name may only include alphabetic characters, no spaces, and is case-sensitive. The value is optional; if you specify a value, then that value will be given to the cookie, and if you don't NetCloak will generate a random value for you.

For example, to create a cookie called "BeenThere" with a value of "DoneThat", use the command:

     <SET_COOKIE BeenThere = "DoneThat">

<INSERT_COOKIE CookieName>

This command will place the contents of the specified cookie into the page. For example, if you have set the "BeenThere" cookie noted above you can display it with:

     Your Cookie Is: <INSERT_COOKIE BeenThere>

Inserted cookies will appear as you would expect, with the value of the cookie inserted at the point at which the INSERT command is placed.

<HIDE_COOKIE CookieName Value1 Value2 ...>

Any HTML text that follows HIDE_COOKIE will be hidden from those users when the specified cookie contains the specified text. An example is included in the SHOW_COOKIE section below.

<SHOW_COOKIE CookieName Value1 Value2 ...>

This command operates exactly like HIDE_COOKIE except that is turns the text stream on instead of turning it off.

For example, assume you have a "planes" page, a "trains" page, and an "automobiles" page on your site. Each of these pages sets the cookie "LastMainPage" to either "planes", "trains", or "autos", accordingly. When the user accesses a form requesting more information, you could use the HTML:

     <HIDE><SHOW_COOKIE LastMainPage "planes">     Airplane information can be received...
     <HIDE><SHOW_COOKIE LastMainPage "trains">     Train information can be received...
     <HIDE><SHOW_COOKIE LastMainPage "autos">     Car information can be received...
     <SHOW>

Here, the cookie "LastMainPage" will always be set to the value defined by the most recently accessed of the three pages.

A simple example of a cookie might be to change the behavior of your server after the user has visited a page or taken some action. For example, you might have a form that asks people which sports car is best... the Porsche Boxter, the Mazda Miata, the BMW Z3, or the Honda DelSol VTEC. You could gather the results using global variables, use local variables to display the relative percentages of each car, and use a cookie to remember that the user has already voted and disallow them from voting again.


[ Command Listing | Table Of Contents ]

Copyright © 1996-7 Maxum Development Corporation
820 South Bartlett Road - Suite 104
Streamwood, IL 60107
http://www.maxum.com/